<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>生产</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 

  <link rel="stylesheet" href="../../res/layuis/css/layui.css">
   <link rel="stylesheet" href="../../res/layuis/css/modules/laydate/default/laydate.css">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript" src="../../res/layuis/lay/modules/laydate.js" charset="utf-8"></script>
  <script type="text/javascript" src="../../res/layuis/layui.js" charset="utf-8"></script>
</head>
<body>
	 
<div class="demoTable" style="margin-top: 10px;width: 100%;float: left;">
 	
    <div class="x-body">
     <div class="layui-input-inline">
    <form class="layui-form" >
    
      
      <div class="layui-input-inline"  style="width:224px;">
       
          <select name="prodPermit" lay-filter="aihao" id="prodPermit">
	       	<option value="">生产许可</option>
	       	<option value="1">等待财务许可</option>
	       	<option value="2">等待总经理许可</option>
	       	<option value="3">已许可</option>
	       	<option value="4">未通过许可</option>
	       	<option value="5">已提交质检</option>
	      </select>
      </div>
       <div class="layui-input-inline"  style="width:224px;">
       
          <select name="manufactureType" lay-filter="aihao" id="manufactureType">
	       	<option value="">制造状态</option>
	       	<option value="0">未制造</option>
	       	<option value="1">已制造</option>
	       	<option value="2">制造完成</option>
	      </select>
      </div>
      <div class="layui-input-inline">
			<input type="text" placeholder="开始日期" class="layui-input" id="startTime" style="width: 224px;height: 38px;">
		</div>
		
		<div class="layui-input-inline">
			<input type="text" placeholder="结束日期"  class="layui-input" id="endTime" style="width: 224px;height: 38px;">
		</div>
      </form>
        </div>
       <div class="layui-input-inline">
         <button class="layui-btn" data-type="reload" lay-filter="sreach" id="productionSreach"><i class="layui-icon">&#xe615;</i></button>
      </div>
     <div style="background: #f0f0f0;margin-top: 20px;padding: 5px;">
        <button class="layui-btn" id="insert"><i class="layui-icon"></i>添加</button>
     </div>
      
    
    
<table class="layui-table" lay-filter="demo" id="production">
	
</table>
<script type="text/javascript">
var prodId="";
layui.use('table',function(){
	  var table = layui.table;
	  var form = layui.form;
		  table.render({
			    elem: '#production'
			    ,page: true
			    ,url:'../../listenProduction/findProduction.action'
			    ,cols: [[
			       {field:'prodId'}
			      ,{field:'prodStartTime',title: '开始时间'}
			      ,{field:'prodEndTime',title: '结束时间'}
			      ,{field:'prodNumber',title: '剩余数量'}
			      ,{field:'prodPermit',title: '进度状态',templet:'#prodPermits'}
			      ,{field:'manufactureType',title: '制造状态',templet:'#manufacturesType'}
			      ,{field:'right', align:'center', toolbar: '#barDemo',title:'操作',width: '500'}
			    ]],id: 'idTest',done: function (res, curr, count) {
		            $("[data-field='prodId']").css('display','none');
		            var tables=table.cache.idTest;
		            
		            
		            $.each(tables,function(i,item){
						prodId=prodId+item.prodId+","
						
						 form.render();
						
	 				});
		           
		            var prodIds=new Array();
		    		prodIds=prodId.split(",");
		    		$.ajaxSetup({
		    			async: false
		    		});
		    		for (var i = 0; i < prodIds.length; i++) {
		    			
		    			if(prodIds[i]){		 
		    				$("#number_"+prodIds[i]).html(0)
		    				var url="../../listenManufacture/findManufactureNumber.action";
		    				  var data={"prodId":prodIds[i]};
		    				  $.post(url,data,function(mes){
		    					  $.each(mes,function(j,item){
		    						 
		    						  $("#number_"+item.prodId).html(parseInt($("#number_"+item.prodId).html())+parseInt(item.mfNoComplete))
		    						  form.render();
		    					  });
		    				  });
		    			}
		    			
		    		}
		    		$.ajaxSetup({
		    			async: true
		    		});
		            
			    }
			  });
  
});


</script>
<script type="text/html" id="manufacturesType">
{{# if(d.manufactureType == 0) { }}
     <div>未制造</div>
 	 {{# } else if(d.manufactureType == 1){ }}
    <div>正在制造</div>
     {{# } else if(d.manufactureType == 2){ }}
    <div>制造完成</div>
{{# }}}
</script>
 
<script type="text/html" id="prodPermits">
{{# if(d.prodPermit == 0) { }}
     <div>未提交审核</div>
 	 {{# } else if(d.prodPermit == 1){ }}
    <div>等待财务许可</div>
 	{{# } else if(d.prodPermit == 2){ }}
    <div>等待总经理许可</div>
	{{# } else if(d.prodPermit == 3){ }}
    <div>已许可</div>
	{{# } else if(d.prodPermit == 4){ }}
    <div>未通过许可</div>
	{{# } else if(d.prodPermit == 5){ }}
    <div>已提交质检</div>

{{# }}}
</script>
<script type="text/html" id="barDemo">
	{{# if(d.prodPermit == 0) { }}
    			<a class="layui-btn layui-btn-xs" lay-event="update">修改</a>
  				<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="auditing">提交审核</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">点击制造</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交质检</a>
	{{# } else if(d.prodPermit == 1) { }}
    			<a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">删除</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交审核</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">点击制造</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交质检</a>
 	 {{# } else if(d.prodPermit == 2){ }}
     			<a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">删除</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交审核</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">点击制造</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交质检</a>
	 {{# } else if(d.prodPermit == 3){ }}
		{{# if(d.manufactureType == 0) { }}
    			<a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">删除</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交审核</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="manufacture">点击制造</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交质检</a>
 	 		{{# } else if(d.manufactureType == 1){ }}
    			<a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">删除</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交审核</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="manufacture">点击制造</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交质检</a>
     		{{# } else if(d.manufactureType == 2){ }}
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">删除</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交审核</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">点击制造</a>
  				<a class="layui-btn layui-btn-xs" lay-event="quality"> 提交质检</a>
			{{# }}}  
     {{# } else if(d.prodPermit == 4){ }}
  				<a class="layui-btn layui-btn-xs" lay-event="update">修改</a>
  				<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交审核</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">点击制造</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交质检</a>
	{{# } else if(d.prodPermit == 5){ }}
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">修改</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">删除</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交审核</a>
  				<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail">生产明细</a>
				<a class="layui-btn layui-btn-disabled layui-btn-xs">点击制造</a>
  				<a class="layui-btn layui-btn-disabled layui-btn-xs">提交质检</a>
{{# }}}



 
</script>
</div>
</div>

 
 
 
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript" src="../../res/js/production/production.js"></script>
</body>
</html>